package cn.kbyue.exceptiondemo.dto;

import cn.kbyue.exceptiondemo.common.validate.AdviceGroupSequenceProvider;
import cn.kbyue.exceptiondemo.common.validate.AdviceSave;
import cn.kbyue.exceptiondemo.common.validate.Save;
import lombok.Data;
import org.hibernate.validator.group.GroupSequenceProvider;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;

/**
 * @author xlang
 * @date 2023/4/4 11:24
 */
@Data
@GroupSequenceProvider(AdviceGroupSequenceProvider.class)
public class AdviceDTO {

    /**
     * 是否添加建议
     */
    @NotNull
    @Pattern(regexp = "^[0-1]$", message = "值只能为0, 1")
    private String enable;

    /**
     * 建议内容
     */
    @NotBlank(message = "开启建议时,建议内容不能为空", groups = AdviceSave.class)
    @Size(min = 1, max = 8, message = "建议内容字数在 {min} 和 {max} 之间", groups = AdviceSave.class)
    private String advice;
}
